<script>
    function mgrApprove(getId,getId2) {
        $.post("<?= site_url() ?>search_global/approve_manager", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "saranaKerja"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function gaApprove(getId,getId3,getId2) {
        $.post("<?= site_url() ?>search_global/approve_ga", {
            cRequestNo : getId,
            cType : getId2,
            pReqForNik : getId3,
            cTab : "saranaKerja"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function gaApprove2(getId,getId2) {
        $.post("<?= site_url() ?>search_global/approve_ga", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "saranaKerja"
        },
        function(data) {
            $('#top').html(data);
        });
    }
    function reqEdit(getId,getId2) {
        $.post("<?= site_url() ?>search_global/edit_req", {
            cRequestNo : getId,
            cType : getId2,
            cTab : "saranaKerja"
        },
        function(data) {
            $('#top').html(data);
        });
    }
</script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/js/select.js" /></script>
<?php

//$this->load->view('header');

if (strlen($this->session->flashdata('Error')) > 0) {
    echo '<div class="alert alert-danger alert-dismissable">';
    echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $this->session->flashdata('Error') . '</div>';
    $this->session->unset_userdata('Error');
} elseif (strlen($this->session->flashdata('Success')) > 0) {
    echo '<div class="alert alert-success alert-dismissable">';
    echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' . $this->session->flashdata('Success') . '</div>';
    $this->session->unset_userdata('Success');
}
?>
<script type="text/javascript">
    function goto_publicRoom() {
        $.post("<?= site_url() ?>search_global/publicRoom", {
            search_by_regional: $('#search_by_regional').val(),
            search_by_status: $('#search_by_status').val(),
            search_by_type: $('#search_by_type').val()
        },
        function(data) {
            $('#top').html(data);
            //$('#container').html(data);
        });
    }
    function goto_services() {
        $.post("<?= site_url() ?>search_global/services", {
            search_by_regional: $('#search_by_regional').val(),
            search_by_status: $('#search_by_status').val(),
            search_by_type: $('#search_by_type').val()
        },
        function(data) {
            $('#top').html(data);
            //$('#container').html(data);
        });
    }
    function search_data() {
        $.post("<?= site_url() ?>search_global/search_saranaKerja", {
            search_by_option: $('#search_by_option').val(),
            search_by_keyword: $('#search_by_keyword').val(),
            search_by_date_start: $('#G_Date1').val(),
            search_by_date_end: $('#G_Date2').val()
        },
        function(data) {
            $('#divload').html(data);
        });
    }

    function edit_data(id) {
        $.post("<?= site_url() ?>setup/edit_area", {id: id}, function(data) {
            $('#loader').html(data);
        });
    }

    function close_popup() {
        $('#dialog').dialog('close');
    }

    function load_page_saranaKerja(page, ipp) {
        $.post("<?= site_url() ?>search_global/load_page_saranaKerja", {
            page: page,
            ipp: ipp,
            search_by_option: $('#search_by_option').val(),
            search_by_date_start: $('#G_Date1').val(),
            search_by_date_end: $('#G_Date2').val(),
            search_by_keyword: $('#search_by_keyword').val()
        },
        function(data) {
            $('#divload').html(data);
        });
    }

    function activation(id, cond) {
        var page = $('#page_val').val();
        var ipp = $('#ipp_val').val();
        var str = 'Are you sure to deactivate this area?';
        if (cond != 'Y') {
            str = 'Are you sure to activate this area?';
        }
        var cek = confirm(str);
        if (cek) {
            $.post("<?= site_url() ?>setup/activation_area", {
                id: id,
                cond: cond
            },
            function(data) {
                load_page_area(page, ipp);
            });
        }
    }

    function add_data() {
        $.post("<?= site_url() ?>setup/add_area", function(data) {
            $('#loader').html(data);
        });
    }
</script>      

<!---
<div class="container">
-->

	<div class="col-md-offset-0" id="top">
		<div class="col-md-11">
			<ul class="nav nav-tabs nav-justified">
			</ul>
			<div class="tab-content">
                <div class="col-md-12 well">
                    <div class="col-md-2">
                        <button type="button" class="btn btn-danger btn-block" disabled="">Sarana Kerja</button>
                    </div>
                    <div class="col-md-2">
                        <button type="button" class="btn btn-danger btn-block" onclick="goto_publicRoom();">Public Room</button>
                    </div>
                    <div class="col-md-2">
                        <button type="button" class="btn btn-danger btn-block" onclick="goto_services();">Services</button>
                    </div>
                </div>
                <form class="form-horizontal" id="access" role="form" method="post" action="#">
                    <div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title"><b class="caret"></b><b> Search Room</b></h4>
						</div>
						<div class="panel-body">
							<div class="col-md-12 well">
								<div class="form-group">
									<label class="control-label col-md-2">Pencarian berdasarkan</label>
									<div class="col-md-4">
										<select class="form-control input-form select2" id="search_by_option" style="width:100%">
											<option value="" selected="">-</option>
                                            <option value="type">TYPE</option>
                                            <option value="requestor">REQUESTOR</option>
                                            <option value="requestor_no">NO. ORDER</option>
										</select>
									</div>
                                    <label class="control-label col-md-1">Keywords</label>
                                    <div class="col-md-5">
                                            <div class="col-md-10">
                                                <input type="text" class="form-control input-sm" id="search_by_keyword" />
                                            </div>
									</div>
								</div>
								
								<div class="form-group">
								    <label class="control-label col-md-2">Date</label>
										<div class="col-md-2">
											<div class="input-group">
                                                <span class="input-group-addon"><small>From</small></span>
								                <input type="text" class="form-control input-sm" autocomplete="off" id="G_Date1" value="<?php echo $date_start_set;?>" />
											</div>
										</div>
                                        <div class="col-md-2">
    								        <div class="input-group">
                                                <span class="input-group-addon"><small>To</small></span>
    								            <input type="text" class="form-control input-sm" autocomplete="off" id="G_Date2" value="<?php echo $date_end_set;?>"/>                                        
    										</div>
    								    </div>
                                    
                                    
                                    <div class="col-md-2">
                                        <button type="button" class="btn btn-primary btn-block" onclick="search_data();">Search</button>
                                    </div>
                                    <div class="col-md-2">
                                        <button type="reset" class="btn btn-default btn-block">Clear</button>
                                    </div>
								</div>
							</div>
						</div>
					</div>
                    </form>                    
                    
                    <div class="panel-body well" id="divload">
                    <div id="tablecontent" class="col-md-12">						
                        <div class="form-group">
                            <div class="table-responsive">
                                <table class="table table-bordered table-condensed table-striped" style="background:#f9f9f9;">
                                    <thead>
                                        <tr>
                                            <th class="tblhead" style="width:5%;text-align:center;">#</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Type</th>
                                            <th class="tblhead" style="width:10%;text-align:center;" colspan="3">Request</th>
                                            <th class="tblhead" style="width:25%;text-align:center;">Description</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Atasan</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">GA Approval</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Closing</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Edit</th>
                                            <th class="tblhead" style="width:10%;text-align:center;">Print</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                        foreach ($list_data as $row) {
                                            $cRecnum        = $row["RECNUM"];    
                                            $cType  		= $row["TYPE"];
                        					$cRequestNo 	= $row["REQUEST_NO"];
                        					$cRequestUrlGa 	= $row["REQUEST_URL_GA"];
                        					$cReqUrl 		= $row["REQ_URL"];
                        					$cRequestUrl 	= $row["REQUEST_URL"];
                        					$cRequestor 	= $row["REQUESTOR"];
                                            $cRequestorName = $row["REQUESTORNAME"];
                        					$cRequesFor 	= $row["REQUEST_FOR"];
                        					$cDescription 	= $row["DESCRIPTION"];
                        					$cSdate  		= $row["SDATE1"];
                        					$cAtasanNik  	= $row["ATASAN_NIK"];
                        					$cAtasanApp  	= $row["ATASAN_APP"];
                        					$cGaApp  		= $row["GA_APP"];
                        					$cItApp  		= $row["IT_APP"];
                        					$cGaFollowup  	= $row["GA_FOLLOWUP"];
                        					$cPrintDokumen 	= $row["PRINT_DOKUMEN"];
                        					$cReqClosing  	= $row["REQ_CLOSING"];
                                            ?>
                                        <tr>
                                            <td style="font-size:10px;"><?php echo $cRecnum;?></td>
                                            <td style="font-size:10px;"><?php echo $cType;?></td>
                                            <td style="font-size:10px;"><?php echo $cRequestor. " - ".$cRequestorName;?></td>
                                            <td style="font-size:10px;"><?php echo $cRequestNo;?></td>
                                            <td style="font-size:10px;"><?php echo $cSdate;?></td>
                                            <td style="font-size:10px;"><?php echo nl2br($cDescription); ?></td>
                                            <td style="font-size:10px;">
                                                <?php 
                                                    //echo $cAtasanApp." / ".$cAtasanNik;
                                                    //var_dump($cAtasanApp);
                                                    if (empty($cAtasanApp)) {/*
                                    					if($cAtasanNik==$nik || $group == 'ADMIN') {
                                    					   $html_atasan = "<a href=\"javascript:FmLov2('$cRequestUrl$cRequestNo')\"><img src=\"images/confirm.png\" border=0></a>";
                                    					}else {
                                    					   $html_atasan = '-';
                                					    }*/
                                                        //$html_atasan=$cRequestUrl.$cRequestNo;
                                                        ?>
                                                        <button type="button" class="btn btn-primary btn-block" onclick="mgrApprove('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                        <?php
                                					} 
                                                    elseif ($cAtasanApp=='N') { 
        				                                //$html_atasan="<img src=\"images_new/ico_cross.gif\" border=0>";
                                                        ?>
                                                        <button type="button" class="btn btn-danger btn-block" disabled="">X</button><?php
                                					} 
                                                    elseif ($cAtasanApp=='Y') { ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                        <?php
                                					} 
                                                ?></td>
                                            <td style="font-size:10px;">
                                            <?php
                                            $html_ga='&nbsp;';
                                            //aktifkan saat ada session group
                        					//if($group == 'ADMIN'){
                            					if(empty($cGaApp)){ //JIKA BELUM DI APPROVE GA
                                    					if($cAtasanApp == 'Y' && $cGaFollowup != 'X'){
                                    					   //$cRequestUrl='./request_ga_app.php?pReqId='
                                    					   //$html_ga="<a href=\"javascript:FmLov2('request_ga_app.php?pReqId=$cRequestNo&pReqForNik=$cRequesFor')\"><img src=\"images/confirm.png\" border=0></a>";
                                                           //echo "A ".$cGaFollowup.">> request_ga_app.php?pReqId=".$cRequestNo."&pReqForNik=".$cRequesFor;
                                                           //JIKA WARNA KUNING, MAKA ADA preqfornik
                                                           ?>
                                                           <button type="button" class="btn btn-warning btn-block" onclick="gaApprove('<?php echo $cRequestNo; ?>','<?php echo $cRequesFor;?>','<?php echo $cType;?>');" >App</button>
                                                            
                                                           <?php
                                    					}
                                                        else if($cAtasanApp == 'Y' && $cGaFollowup == 'X'){
                                    					   //$html_ga="<a href=\"javascript:FmLov2('$cRequestUrlGa$cRequestNo')\"><img src=\"images/confirm.png\" border=0></a>";
                                                           //echo "B ".$cGaFollowup.">> ".$cRequestUrlGa."\\".$cRequestNo;
                                                           ?>
                                                           <button type="button" class="btn btn-primary btn-block" onclick="gaApprove2('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                           <?php
                                    					}
                                                        else{
                                    					   ?>-<?php
                                    					}
                                					}
                                                else{
                                					if($cGaApp == 'Y'){
                                					    ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                        <?php
                                					}elseif($cGaApp == 'N'){
                                					    ?>
                                                        <button type="button" class="btn btn-danger btn-block" disabled="">X</button>
                                                        <?php
                                					}
                                                    //Disable sementara cType, tar kerjain
                                                    /*
                                					if( $cType == 'LOT PARKIR'){
                                    					$qryx = "select parkird_status from fm_parkir_det where parkird_id='$cRequestNo'";
                                    	                $DB1->parse($qryx);
                                    					$DB1->execute();
                                    					if($q=$DB1->nextrow()){
          		                                            $qParkirdStatus= $q["PARKIRD_STATUS"];
                                    					}
                                    																			
                                    					if($qParkirdStatus == 'Y'){
                                    					   $html_ga.="<a href=\"javascript:FmLov2('parkir_deactivate.php?pParkirdId=$cRequestNo');\"><img src=\"images/confirm.png\" border=0></a>";
                                    					}else{
                                    					   $html_ga.="Deactivated";
                                    					}
                                					}*/
                            					}
                        					//}else{
                        					//   $html_ga="-";
                        					//}
                                            ?>
                                            </td>
                                            <td style="font-size:10px;">
                                            <?php
                                                if(!empty($cReqClosing)){
                                                    //tambahan
                                                    if($cReqClosing=='Y'){
                                                        ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">V</button>
                                                        <?php
                                                    }
                                                    else{
                                                        ?>
                                                        <button type="button" class="btn btn-success btn-block" disabled="">N</button>
                                                        <?php    
                                                    }
                                                    
                                                }
                                                else{
                                                    if(!empty($cAtasanApp)) {
                                                        ?>
                                                        <button type="button" class="btn btn-primary btn-block" onclick="reqClosing('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >App</button>
                                                        <?php
    												}
                                                    else{
    													?>
                                                        <button type="button" class="btn btn-warning btn-block" disabled="">App</button>
                                                        <?php
    												}
    											}
                                            ?>
                                            </td>
                                            <td style="font-size:10px;"></td>
                                            <td style="font-size:10px;">
                                            <?php
                                            //$html_edit='&nbsp;';
                                            //aktifkan saat ada session group
					                        //if($nik == $cRequestor || $group == 'ADMIN'){
                                                if(!empty($cGaApp)){
												    if($cType == 'MEETING ROOM') {
													   //$html_edit="<a href=\"javascript:FmLov2('room_edit.php?pRoomId=$cRequestNo');\" alt=\"Cetak Dokumen\"><img src=\"images_new/ico_edit2.gif\" border=0></a>";
                                                       ?>
                                                       MEETING
                                                       <?php
												    }
                                                    else {
													   //$html_edit="-";
                                                       ?>
                                                       -
                                                       <?php
													}
												}
                                                else{
													//$html_edit="<a href=\"$cReqUrl$cRequestNo\" alt=\"Cetak Dokumen\"><img src=\"images_new/ico_edit2.gif\" border=0></a>";
                                                    ?>
                                                    <button type="button" class="btn btn-primary btn-block" onclick="reqEdit('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >Edit</button>
                                                    <?php
												}
											//}else{
											//	$html_edit="-";
											//}
                                            ?>
                                            </td>
                                            <td style="font-size:10px;">
                                            <?php
                                            if(!empty($cGaApp) && $cGaApp == 'Y'){
                                                ?>
                                                <button type="button" class="btn btn-primary btn-block" onclick="reqPrint('<?php echo $cRequestNo; ?>','<?php echo $cType;?>');" >Print</button>
                                                <?php
											}
                                            else{
											     $html_print="-";
											}
                                            ?>
                                            </td>
                                        </tr>
                                        <?php
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="form-group">
                            <div id="mypaging">
                                <?php
                                echo $paging;
                                echo $jump_page;
                                echo $ipp;
                                ?>
                            </div>								
                        </div>						
                    </div>
                </div>
                
                
			</div>
      


